package com.ruoyi.whzj.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.whzj.mapper.WhActivityMapper;
import com.ruoyi.whzj.domain.WhActivity;
import com.ruoyi.whzj.service.IWhActivityService;
import com.ruoyi.common.core.text.Convert;

/**
 * 活动Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-10-22
 */
@Service
public class WhActivityServiceImpl implements IWhActivityService 
{
    @Autowired
    private WhActivityMapper whActivityMapper;

    /**
     * 查询活动
     * 
     * @param id 活动ID
     * @return 活动
     */
    @Override
    public WhActivity selectWhActivityById(String id)
    {
        return whActivityMapper.selectWhActivityById(id);
    }

    /**
     * 查询活动列表
     * 
     * @param whActivity 活动
     * @return 活动
     */
    @Override
    public List<WhActivity> selectWhActivityList(WhActivity whActivity)
    {
        return whActivityMapper.selectWhActivityList(whActivity);
    }

    /**
     * 获取最新的一个活动
     * @return
     */
    @Override
    public WhActivity selectActivityNew()
    {
        return whActivityMapper.selectActivityNew();
    }

    /**
     * 新增活动
     * 
     * @param whActivity 活动
     * @return 结果
     */
    @Override
    public int insertWhActivity(WhActivity whActivity)
    {
        whActivity.setId(IdWorker.getId());
        whActivity.setCreateTime(DateUtils.getNowDate());
        return whActivityMapper.insertWhActivity(whActivity);
    }

    /**
     * 修改活动
     * 
     * @param whActivity 活动
     * @return 结果
     */
    @Override
    public int updateWhActivity(WhActivity whActivity)
    {
        return whActivityMapper.updateWhActivity(whActivity);
    }

    /**
     * 删除活动对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWhActivityByIds(String ids)
    {
        return whActivityMapper.deleteWhActivityByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除活动信息
     * 
     * @param id 活动ID
     * @return 结果
     */
    @Override
    public int deleteWhActivityById(String id)
    {
        return whActivityMapper.deleteWhActivityById(id);
    }
}
